package com.PAT.UnSatisfying;

import java.util.HashSet;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/12/29/21:00
 * @Description:
 * @Target: 差10
 */
public class 危险品装箱 {

    // N是成对的不相容物品的对数
    // M是集装箱货品清单的单数
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.nextLine();
        String[] s = s1.split(" ");

        int N = Integer.valueOf(s[0]);
        int M = Integer.valueOf(s[1]);

        String[] NArray = new String[N];
        String[] MArray = new String[M];
        for (int i = 0; i < N; i++) {
            NArray[i] = in.nextLine();
        }

        for (int i = 0; i < M; i++) {
            MArray[i] = in.nextLine();
        }
        Execute(NArray,MArray);


    }


    public static void Execute(String[] s1,String[] s2){
        for (int i = 0; i < s2.length; i++) {
            String[] tempArray = s2[i].split(" ");
            HashSet tempSet = new HashSet();
            boolean tempFlag = false;
            for (String s : tempArray) {
                tempSet.add(s);
            }

            for (int j = 0; j < s1.length; j++) {
                String[] tempArray1 = s1[j].split(" ");
                if (tempSet.contains(tempArray1[0])&&tempSet.contains(tempArray1[1])){
                    tempFlag = true;
                    break;
                }
            }

            if (tempFlag == true){
                System.out.println("No");
            }else {
                System.out.println("Yes");
            }

        }
    }

}
